package rubik;

import java.awt.BorderLayout;
import java.awt.Dimension;
import javax.swing.JFrame;

public class CubeGraphics extends JFrame {
    private final Dimension d = new Dimension(800,600);
    private int treshold;
    private CubeCanvas cc;
    public CubeGraphics(Cube cube) {
        treshold = 0;
        this.setTitle("Cubo di Rubik");
        this.setSize(d);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        cc = new CubeCanvas(this, cube);
        this.setSize(new Dimension(787,614));//796,623));
        this.add(cc,BorderLayout.CENTER);
        this.setLocationRelativeTo(null);
        this.setResizable(false);
        this.setVisible(true);
    }
    
    public void forceUpdate(Cube cube, boolean override) {
        if (treshold > 50000 || override) {
            cc.setCube(cube);
            cc.update(cc.getGraphics());
            treshold = 0;
        }
        else treshold++;
    }
}
